// Definition of the Socket class

#ifndef Socket_class
#define Socket_class


#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <string>
#include <arpa/inet.h>
#include <iostream>
//Pour les transformation d'entier vers string et inversement
#include <sstream>

using namespace std;

const int MAXHOSTNAME = 200;
const int MAXCONNECTIONS = 10;
const int MAXRECV = 500;

class Socket{

public:
	Socket();
	virtual ~Socket();

// Initialisation du serveur
	bool create();
	bool bind(const int port);
	bool listen() const;
	bool accept (Socket&) const;

// Initialisation du client
	bool connect (const string host, const int port);

// Transmission des données
	bool send(const string) const;
	bool send(const int) const;
	
	int recv(string&) const;
	int recv(int&) const;

	void set_non_blocking (const bool);

	bool is_valid() const {
		return m_sock != -1;
	}

private:

	int m_sock;
	sockaddr_in m_addr;

};


#endif
